using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_INVOICEDETAILMap : EntityTypeConfiguration<SO_INVOICEDETAIL>
    {
        public SO_INVOICEDETAILMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ITEM, t.DESCRIPTION, t.QTYSHIP, t.TYPE, t.SYMBOL, t.EXTENDED_AMOUNT, t.PRICE, t.PATIENT_AMOUNT, t.GUARANTOR1_AMOUNT, t.GUARANTOR2_AMOUNT, t.DISCOUNT_PERCENTAGE, t.DISCOUNT_AMOUNT, t.INS1PERC, t.INS2PERC, t.SUMFIELDS });

            // Properties
            this.Property(t => t.NUMBER)
                .HasMaxLength(8);

            this.Property(t => t.ITEM)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.DESCRIPTION)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.LOCATION)
                .HasMaxLength(3);

            this.Property(t => t.TYPE)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.SYMBOL)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.MASTERITEM)
                .HasMaxLength(10);

            this.Property(t => t.SUMFIELDS)
                .IsRequired()
                .HasMaxLength(51);

            // Table & Column Mappings
            this.ToTable("SO_INVOICEDETAIL");
            this.Property(t => t.NUMBER).HasColumnName("NUMBER");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.DESCRIPTION).HasColumnName("DESCRIPTION");
            this.Property(t => t.LOCATION).HasColumnName("LOCATION");
            this.Property(t => t.QTYSHIP).HasColumnName("QTYSHIP");
            this.Property(t => t.ENTRY_DATE).HasColumnName("ENTRY_DATE");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.SYMBOL).HasColumnName("SYMBOL");
            this.Property(t => t.EXTENDED_AMOUNT).HasColumnName("EXTENDED_AMOUNT");
            this.Property(t => t.PRICE).HasColumnName("PRICE");
            this.Property(t => t.PATIENT_AMOUNT).HasColumnName("PATIENT_AMOUNT");
            this.Property(t => t.GUARANTOR1_AMOUNT).HasColumnName("GUARANTOR1_AMOUNT");
            this.Property(t => t.GUARANTOR2_AMOUNT).HasColumnName("GUARANTOR2_AMOUNT");
            this.Property(t => t.DISCOUNT_PERCENTAGE).HasColumnName("DISCOUNT_PERCENTAGE");
            this.Property(t => t.DISCOUNT_AMOUNT).HasColumnName("DISCOUNT_AMOUNT");
            this.Property(t => t.OPERATIONSERIAL).HasColumnName("OPERATIONSERIAL");
            this.Property(t => t.EXPIRYDATE).HasColumnName("EXPIRYDATE");
            this.Property(t => t.INS1PERC).HasColumnName("INS1PERC");
            this.Property(t => t.INS2PERC).HasColumnName("INS2PERC");
            this.Property(t => t.MASTERITEM).HasColumnName("MASTERITEM");
            this.Property(t => t.SUMFIELDS).HasColumnName("SUMFIELDS");
        }
    }
}
